from django.db import models

# Create your models here.
from user.models import User


class Chat (models.Model):
    chat_id = models.AutoField (verbose_name='聊天编号', primary_key=True)
    # user_id = models.ForeignKey (User, models.DO_NOTHING, db_column='user_id', db_index=True)
    # another_user_id = models.ForeignKey (User, models.DO_NOTHING, db_column='user_id', db_index=True)
    user_id = models.IntegerField(verbose_name="用户1", default=0)
    another_user_id = models.IntegerField(verbose_name="用户2", default=0)

    def __str__(self):
        return  str(self.chat_id)

    class Meta:
        db_table = 'tb_chat'
        # ordering = ['char_id']
        verbose_name_plural = verbose_name = '聊天表'


class Message:
    sequence_id = models.AutoField(verbose_name="聊天记录ID", max_length=8, primary_key=True)
    from_id = models.CharField(verbose_name='发送者id',max_length=8)
    to_id = models.CharField(verbose_name='接受者id',max_length=8)
    chat_send_time = models.DateTimeField(verbose_name='发送时间',auto_now=True)
    chat_content = models.TextField(verbose_name='私信内容')